package cn.gailvlun.gll.presentation.chat.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import java.util.List;

import cn.gailvlun.gll.presentation.chat.PhotoFragment;



public class PhotoListPagerAdapter extends FragmentStatePagerAdapter {

    private List<String> photos;

    public PhotoListPagerAdapter(FragmentManager fm, List<String> photos) {
        super(fm);
        this.photos = photos;
    }

    @Override
    public Fragment getItem(int position) {
        return PhotoFragment.newInstance(photos.get(position), position);
    }

    @Override
    public int getCount() {
        return photos.size();
    }

    private PhotoFragment mCurrentFragment;

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        mCurrentFragment = (PhotoFragment) object;
    }

    public PhotoFragment getCurrentFragment() {
        return mCurrentFragment;
    }
}
